package com.wntms.wy.dao;

import com.wntms.wy.pojo.ErrorInformation;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ErrorInformationDao {

    //在输入fid后先查询业务员验收表和客户验收表必须有一个不通过，才可以填写
    @Select("select count(*) from freight_contract where fid=#{fid}")
    int panduanFCByFid(String fid);
    //还得查一下是否有验收单
    @Select("select count(*) from salesman_accept where fid=#{fid}")
    int findSalesmanCountByFid(String fid);
    @Select("select ispass from salesman_accept where fid=#{fid}")
    Boolean findSalesmanIspassByFid(String fid);
    @Select("select count(*) from customer_accept where fid=#{fid}")
    int findCustomerCountByFid(String fid);
    @Select("select ispass from customer_accept where fid=#{fid}")
    Boolean findCustomerIspassByFid(String fid);
    //还要是否已经填写
    @Select("select count(*) from error_information where fid=#{fid}")
    int findEIByFid(String fid);
    //在前端差错信息表应该显示：货运单合同表id、验收表编号,差错信息名称，原因和图片
    //前端要传回来 fid, 差错信息名称，原因和图片
    //差错信息表增加
    //先找到验收表编号
    @Select("select id from salesman_accept where fid=#{fid}")
    Integer findIspassIdByfid1(String fid);
    @Select("select caid from customer_accept where fid=#{fid}")
    Integer findIspassIdByfid2(String fid);
    @Insert("insert into error_information (fid,id,errorname,errorreason,errorimg) values (#{fid},#{id},#{errorname},#{errorreason},#{errorimg})")
    int addErrorInformation(ErrorInformation errorInformation);
    @Delete("delete from error_information where eiid = #{id}")
    int deleteErrorInformation(Integer id);

    @Update("update error_information set errorname=#{errorname},errorreason=#{errorreason},errorimg=#{errorimg} where eiid=#{eiid}")
    int updateErrorInformation(ErrorInformation errorInformation);
    @Select("select * from error_information")
    List<ErrorInformation> findAllErrorInformation();
}
